log using "C:\Users\J.PARK\Dropbox\Discrimination Project_for me\Organizational Diversity\2023 Version_Merging\FINAL\CFA_2010.smcl", replace  

import delimited "C:\Users\J.PARK\Dropbox\DISCRIMINATION PROJECT\FEVS\FEVS_2010-2019\FEVS2010_PRDF.csv"
drop if q17=="X"
drop if q17==""
drop if q37=="X"
drop if q37==""
drop if q38=="X"
drop if q38==""
drop if q15=="X"
drop if q15==""
drop if q22=="X"
drop if q22==""
drop if q25=="X"
drop if q25==""
drop if q33=="X"
drop if q33==""
drop if q48==.
drop if q49==.
destring q17, replace
destring q37, replace
destring q38, replace
destring q15, replace
destring q22, replace
destring q25, replace
destring q33, replace
drop if q55=="X"
drop if q55==""
drop if q45=="X"
drop if q45==""
drop if q34=="X"
drop if q34==""
destring q55, replace
destring q45, replace
destring q34, replace
drop if dsuper=="X"
drop if dsuper==""
drop if dsex=="X"
drop if dsex==""
drop if dminority==.
gen minority = 0 if dminority==2
replace minority = 1 if dminority==1
gen gender = 1 if dsex == "B"
replace gender = 0 if dsex == "A"
gen supervisor = 1 if dsuper == "B" | dsuper == "C"
replace supervisor = 0 if dsuper == "A"

svyset [pweight=postwt]
svy linearized : sem (JUSTICE -> DISTRIBUTIVE, ) (JUSTICE -> PROCEDURAL, ) (JUSTICE -> INTERPERSONAL, ) (DISTRIBUTIVE -> q22, ) (DISTRIBUTIVE -> q25, ) (DISTRIBUTIVE -> q33, ) (PROCEDURAL -> q15, ) (PROCEDURAL -> q17, ) (PROCEDURAL -> q37, ) (PROCEDURAL -> q38, )(INTERPERSONAL -> q48, ) (INTERPERSONAL -> q49, ), standardized latent(JUSTICE DISTRIBUTIVE PROCEDURAL INTERPERSONAL ) nocapslatent
estat gof, stats(all)
predict justice, latent(JUSTICE)

svy linearized : sem (DIVERSITY -> q34, ) (DIVERSITY -> q45, ) (DIVERSITY -> q55, ), standardized latent(DIVERSITY) nocapslatent
estat gof, stats(all)
predict diversity, latent(DIVERSITY)

keep if agency =="AM" | agency =="IB" | agency =="FQ" | agency =="ED" | agency =="DN" | agency =="HU" | agency =="ST" | agency =="EP" | agency =="EE" | agency =="FC" | agency =="FT" | agency =="GS" | agency =="NN" | agency =="NQ" | agency =="CU" | agency =="SN" | agency =="NL" | agency =="NF" | agency =="NU" | agency =="OM" | agency =="BG" | agency =="RR" | agency =="SE" | agency =="SB" | agency =="SZ" | subelem =="DD34" | subelem =="DD10" | subelem =="DD63" | subelem =="DD35" | subelem =="DD04" | subelem =="DD07" | subelem =="DD27" | subelem =="DD60" | subelem =="AG03" | subelem =="AGFA" | subelem =="AG37" | subelem =="AG11" | subelem =="AG16" | subelem =="AG90" | subelem =="CM63" | subelem =="CM55" | subelem =="CM57" | subelem =="CM54" | subelem =="CM56" | subelem =="DD16" | subelem =="HE90" | subelem =="HE39" | subelem =="HE70" | subelem =="HE36" | subelem =="HE34" | subelem =="HE37" | subelem =="HE38" | subelem =="HE10" | subelem =="HSCB" | subelem =="HSBE" | subelem =="HSBC" | subelem =="HSAB" | subelem =="HSAC" | subelem =="HSBD" | subelem =="HSBB" | subelem =="HSAD" | subelem =="DJ15" | subelem =="DJ03" | subelem =="DEA" | subelem =="DJ12" | subelem =="DJ09" | subelem =="DJ02" | subelem =="DJ08" | subelem =="DJ11" | subelem =="DLLS" | subelem =="DLET" | subelem =="DLMS" | subelem =="DLSH" | subelem =="DLPW" | agency =="AF" | agency =="AR" | subelem =="IN06" | subelem =="IN05" | subelem =="IN07" | subelem =="IN15" | subelem =="IN08" | subelem =="IN10" | subelem =="IN01" | agency =="NV" | subelem =="TRAI" | subelem =="TR91" | subelem =="TR93" | subelem =="TRAJ" | subelem =="TRTG" | subelem =="TRAD" | subelem =="TD02" | subelem =="TD03" | subelem =="VAPA" | subelem =="VALA" | subelem =="VATA" | subelem =="DD21"

svy linearized : sem (JUSTICE -> DISTRIBUTIVE, ) (JUSTICE -> PROCEDURAL, ) (JUSTICE -> INTERPERSONAL, ) (DISTRIBUTIVE -> q22, ) (DISTRIBUTIVE -> q25, ) (DISTRIBUTIVE -> q33, ) (PROCEDURAL -> q15, ) (PROCEDURAL -> q17, ) (PROCEDURAL -> q37, ) (PROCEDURAL -> q38, )(INTERPERSONAL -> q48, ) (INTERPERSONAL -> q49, ), standardized latent(JUSTICE DISTRIBUTIVE PROCEDURAL INTERPERSONAL ) nocapslatent
estat gof, stats(all)
predict justice2, latent (JUSTICE)

svy linearized : sem (DIVERSITY -> q34, ) (DIVERSITY -> q45, ) (DIVERSITY -> q55, ), standardized latent(DIVERSITY) nocapslatent
estat gof, stats(all)
predict diversity2, latent (DIVERSITY)

sum justice, detail
sum justice2, detail
sum diversity, detail
sum diversity2, detail
corr justice justice2
corr diversity diversity2 

log close


